package com.aaa.whj.Service.Impl;

import com.aaa.whj.Service.StudentService;
import com.aaa.whj.dao.StudentDao;
import com.aaa.whj.entity.Student;
import com.aaa.whj.vo.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/17  18:01
 */
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;

    @Override
    public Result selectAll(Integer currentPage, Integer pageSize) {
        Page<Student> page = new Page<>(currentPage,pageSize);
        Page<Student> page1 = studentDao.selectPage(page,null);

//        List<Student> all = studentDao.selectAll();
//        PageInfo<Student> pageInfo=new PageInfo<>(all);
        return new Result(200,"查询成功",page1);
    }

    @Override
    public Result addStudent(Student student) {
        studentDao.insert(student);
        return new Result(200,"添加成功");
    }

    @Override
    public Result deleteStudent(Integer id) {
        studentDao.deleteById(id);
        return new Result(200,"删除成功");
    }

    @Override
    public Result updateStudent(Student student) {
        studentDao.updateById(student);
        return new Result(200,"修改成功");
    }
}
